<?php
if(!isset($pre)) $pre="";
if(isset($_SESSION['sql-pre'])) $pre=$_SESSION['sql-pre'];

$sql['table'][]="DROP TABLE IF EXISTS `".$pre."ally`;";
$sql['table'][]="DROP TABLE IF EXISTS `".$pre."fleet`;";
$sql['table'][]="DROP TABLE IF EXISTS `".$pre."forschung`;";
$sql['table'][]="DROP TABLE IF EXISTS `".$pre."group`;";
$sql['table'][]="DROP TABLE IF EXISTS `".$pre."planet`;";
$sql['table'][]="DROP TABLE IF EXISTS `".$pre."users`;";

$sql['table'][]="CREATE TABLE  `".$pre."ally` (
  `ally_id` int(11) NOT NULL auto_increment,
  `ally_name` varchar(30) NOT NULL,
  `ally_tag` varchar(10) NOT NULL,
  `color_red` smallint(6) default NULL,
  `color_green` smallint(6) default NULL,
  `color_blue` smallint(6) default NULL,
  `show_rangliste` smallint(6) default NULL,
  `show_planeten` smallint(6) default NULL,
  `ally_politic` smallint(6) default '2',
  `ally_sort` int(11) NOT NULL,
  PRIMARY KEY  (`ally_id`)
);";
$sql['table'][]="CREATE TABLE  `".$pre."fleet` (
  `fleet_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL,
  `fleet_kt` int(11) NOT NULL default '0',
  `fleet_gt` int(11) NOT NULL default '0',
  `fleet_lj` int(11) NOT NULL default '0',
  `fleet_sj` int(11) NOT NULL default '0',
  `fleet_xer` int(11) NOT NULL default '0',
  `fleet_ss` int(11) NOT NULL default '0',
  `sxer` int(11) NOT NULL default '0',
  `fleet_sk` int(11) NOT NULL default '0',
  `fleet_ks` int(11) NOT NULL default '0',
  `fleet_recy` int(11) NOT NULL default '0',
  `fleet_spio` int(11) NOT NULL default '0',
  `fleet_bomb` int(11) NOT NULL default '0',
  `fleet_zer` int(11) NOT NULL default '0',
  `fleet_tod` int(11) NOT NULL default '0',
  PRIMARY KEY  (`fleet_id`)
);";
$sql['table'][]="CREATE TABLE  `".$pre."forschung` (
  `forschung_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL,
  `forschung_spionagetechnik` tinyint(4) NOT NULL default '0',
  `forschung_waffentechnik` tinyint(4) NOT NULL default '0',
  `forschung_computertechnik` tinyint(4) NOT NULL default '0',
  `forschung_schildtechnik` tinyint(4) NOT NULL default '0',
  `forschung_raumschiffpanzerung` tinyint(4) NOT NULL default '0',
  `forschung_energietechnik` tinyint(4) NOT NULL default '0',
  `forschung_hyperraumtechnik` tinyint(4) NOT NULL default '0',
  `forschung_verbrennungstriebwerk` tinyint(4) NOT NULL default '0',
  `forschung_impulstriebwerk` tinyint(4) NOT NULL default '0',
  `forschung_hyperraumantrieb` tinyint(4) NOT NULL default '0',
  `forschung_lasertechnik` tinyint(4) NOT NULL default '0',
  `forschung_ionentechnik` tinyint(4) NOT NULL default '0',
  `forschung_plasmatechnik` tinyint(4) NOT NULL default '0',
  `forschung_expeditionstechnik` tinyint(4) NOT NULL default '0',
  `forschung_forschungsnetzwerk` tinyint(4) NOT NULL default '0',
  `forschung_gravitonforschung` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`forschung_id`)
);";
$sql['table'][]="CREATE TABLE  `".$pre."group` (
  `group_id` int(11) NOT NULL auto_increment,
  `group_key` int(11) NOT NULL,
  `group_title` tinytext NOT NULL,
  `group_info` text NOT NULL,
  PRIMARY KEY  (`group_id`)
);";
$sql['table'][]="CREATE TABLE  `".$pre."planet` (
  `planet_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL,
  `planet_name` tinytext NOT NULL,
  `planet_kords` varchar(8) NOT NULL,
  `planet_type` tinytext NOT NULL,
  `planet_tmp` int(11) NOT NULL default '0',
  `planet_moon` int(1) NOT NULL default '0',
  `planet_adepot` int(2) NOT NULL default '0',
  `planet_mine_met` int(2) NOT NULL default '0',
  `planet_mine_kris` int(2) NOT NULL default '0',
  `planet_mine_deut` int(2) NOT NULL default '0',
  `planet_diameter` int(5) NOT NULL default '0',
  `planet_spower` int(2) NOT NULL default '0',
  `planet_fpower` int(2) NOT NULL default '0',
  `planet_robo` int(2) NOT NULL default '0',
  `planet_nani` int(2) NOT NULL default '0',
  `planet_terra` int(2) NOT NULL default '0',
  `planet_rwerft` int(2) NOT NULL default '0',
  `planet_pod_met` int(2) NOT NULL default '0',
  `planet_pod_kris` int(2) NOT NULL default '0',
  `planet_pod_deut` int(2) NOT NULL default '0',
  `planet_raksilo` int(2) NOT NULL default '0',
  `planet_forschung` int(2) NOT NULL default '0',
  `planet_solsat` int(6) NOT NULL default '0',
  `moon_diameter` int(3) NOT NULL default '0',
  `moon_robo` int(2) NOT NULL default '0',
  `moon_rwerft` int(2) NOT NULL default '0',
  `moon_pod_met` int(2) NOT NULL default '0',
  `moon_pod_kris` int(2) NOT NULL default '0',
  `moon_pod_deut` int(2) NOT NULL default '0',
  `moon_adepot` int(2) NOT NULL default '0',
  `moon_base` int(2) NOT NULL default '0',
  `moon_phalanx` int(2) NOT NULL default '0',
  `moon_stor` int(2) NOT NULL default '0',
  `moon_def_rak` int(7) NOT NULL default '0',
  `moon_def_ll` int(7) NOT NULL default '0',
  `moon_def_sl` int(7) NOT NULL default '0',
  `moon_def_g` int(7) NOT NULL default '0',
  `moon_def_i` int(7) NOT NULL default '0',
  `moon_def_p` int(7) NOT NULL default '0',
  `moon_def_ks` int(1) NOT NULL default '0',
  `moon_def_gs` int(1) NOT NULL default '0',
  `planet_def_rak` int(11) NOT NULL default '0',
  `planet_def_ll` int(11) NOT NULL default '0',
  `planet_def_sl` int(11) NOT NULL default '0',
  `planet_def_g` int(11) NOT NULL default '0',
  `planet_def_i` int(11) NOT NULL default '0',
  `planet_def_p` int(11) NOT NULL default '0',
  `planet_def_ks` int(11) NOT NULL default '0',
  `planet_def_gs` int(11) NOT NULL default '0',
  `planet_def_abfang` int(11) NOT NULL default '0',
  `planet_def_irak` int(11) NOT NULL default '0',
  PRIMARY KEY  (`planet_id`)
);";
$sql['table'][]="CREATE TABLE  `".$pre."users` (
  `user_id` int(11) NOT NULL auto_increment,
  `pass` text NOT NULL,
  `pass_recover` text NOT NULL,
  `user_group` smallint(7) NOT NULL default '0',
  `user_name` varchar(30) NOT NULL,
  `user_mail` varchar(30) default NULL,
  `user_ally` int(11) default NULL,
  `user_regdate` int(11) NOT NULL,
  `login_date` int(11) NOT NULL default '0',
  `login_active` smallint(6) default '0',
  `login_hash` text,
  `show_bild` tinyint(4) NOT NULL default '0',
  `show_text` tinyint(4) NOT NULL default '0',
  `show_addlinks` tinyint(4) NOT NULL default '0',
  `show_planets` tinyint(1) NOT NULL,
  `user_skin` text NOT NULL,
  `mine_show` tinyint(4) NOT NULL default '0',
  `mine_x` mediumint(9) NOT NULL default '250',
  `mine_y` mediumint(9) NOT NULL default '50',
  `mine_schrift` tinyint(4) NOT NULL,
  `mine_bg` text NOT NULL,
  `mine_textcolor` text NOT NULL,
  `login_ip` varchar(15) NOT NULL,
  PRIMARY KEY  (`user_id`)
);";

if(isset($_SESSION['user_pass'], $_SESSION['user_name'], $_SESSION['user_mail'])){
	$sql['new_user'][]="INSERT INTO `".$pre."users` SET user_id=1, pass='".sha1($_SESSION['user_pass'])."', user_group=1000, user_name='".$_SESSION['user_name']."', user_mail='".$_SESSION['user_mail']."', user_ally=1, user_regdate=".time().", login_active=1;";
	$sql['new_user'][]="INSERT INTO `".$pre."group` SET group_key=1000, group_title='Administratoren', group_info='Dies ist die Grupper der Administatoren, sie besitzt uneingeschränken Zugriff auf das Tool. NICHT LÖSCHEN';";
	$sql['new_user'][]="INSERT INTO `".$pre."group` SET group_key=100, group_title='Standard Gruppe', group_info='Dies ist eine Standard Gruppe die für sie angelegt wurde. Diese Benutzer können alle Daten des Tools betrachten jedoch nur ihre eigenen Bearbeiten.';";
	$sql['new_user'][]="INSERT INTO `".$pre."group` SET group_key=0, group_title='Unregistriert', group_info='Benutzer die nicht angemeldet sind, werden automatisch zugewiesen. NICHT LÖSCHEN';";
	$sql['new_user'][]="INSERT INTO `".$pre."forschung` SET forschung_id=1, user_id=1;";
	$sql['new_user'][]="INSERT INTO `".$pre."fleet` SET fleet_id=1, user_id=1;";
	$sql['new_user'][]="INSERT INTO `".$pre."ally` (ally_id, ally_name, ally_tag, color_red, color_green, color_blue, show_rangliste, show_planeten, ally_politic, ally_sort) VALUES (1,'Beispielallianz','BSP',200,200,200,1,1,2,10);";
};

#$sql['v218'][]=

?>